package com.hrp.hrpdao;

import com.hrp.domain.TransportRecord;
import com.hrp.domain.UimmsReceiveMoney;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/5/6 0006.
 */
@Mapper
public interface ReceiveMoneyDao {

    @Select("<script>"
            + " select * from ( select *,ROW_NUMBER() over(order by id desc) row from UIMMS_RECEIVEMONEY ) T where row in "
            + "<foreach item='item' index='index' collection='strList' open='(' separator=',' close=')'>"
            + "#{item}"
            + "</foreach>"
            + "</script>")
    List<UimmsReceiveMoney> getReceiveMoneyRecordByPage(@Param("strList") List<Integer> strList);

    @Select("select count(*) total from UIMMS_RECEIVEMONEY")
    Integer getTotalCount();

    @Select("select * from UIMMS_RECEIVEMONEY where id = #{id}")
    UimmsReceiveMoney getReceiveMoneyRecordById(@Param("id") Integer id);

    @Insert("   insert into [UIMMS_RECEIVEMONEY]([receiverId],[receiverName],[receiverTime],[money],[updateTime],[insertTime],[czry],[memo]) values (#{receiverId},#{receiverName},#{receiverTime},#{money},GETDATE(),GETDATE(),#{czry},#{memo}) ")
    @Options(useGeneratedKeys=true,keyProperty="id")
    void saveReceiveMoneyRecord(UimmsReceiveMoney uimmsReceiveMoney);

    @Update("update [UIMMS_RECEIVEMONEY] set receiverId=#{receiverId},receiverName=#{receiverName},receiverTime=#{receiverTime},[money]=#{money},updateTime=#{updateTime},czry=#{czry},memo=#{memo} where id=#{id} ")
    void updateReceiveMoneyRecord(UimmsReceiveMoney uimmsReceiveMoney);

    @Options(statementType= StatementType.CALLABLE)
    @Select({ "exec usp_uimms_getReceiveMoneyForProc #{sendTimeKsrq},#{sendTimeJsrq},#{receiverIdStr}" })
    List<Map<String,String>> getReceiveMoneyDataSummaryForProc(Map<String, String> params);
}
